//
//  WPSecondView.m
//  wobingwoyi
//
//  Created by WGP on 16/7/27.
//  Copyright © 2016年 WGP. All rights reserved.
//

#import "WPMineSecondView.h"

@interface WPMineSecondView ()

@end

@implementation WPMineSecondView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        [self setupUI];
    }
    return self;
}

-(void)setupUI
{
    
    WPMineButton *firstBtn = [WPMineButton mineBtnWith:@"binglidangan" title:@"病历档案" mineBtnType:WPMineBtnTypesFirst];
     WPMineButton *secondBtn = [WPMineButton mineBtnWith:@"jkdangan" title:@"体检档案" mineBtnType:WPMineBtnTypesSecond];
     WPMineButton *thirdBtn = [WPMineButton mineBtnWith:@"shoucangjilu" title:@"我的收藏" mineBtnType:WPMineBtnTypesThird];
     WPMineButton *fourthBtn = [WPMineButton mineBtnWith:@"wodejinbi" title:@"我的医票" mineBtnType:WPMineBtnTypesFourth];
     WPMineButton *fifthBtn = [WPMineButton mineBtnWith:@"yibi" title:@"我的医币" mineBtnType:WPMineBtnTypesFifth];
     WPMineButton *sixthBtn = [WPMineButton mineBtnWith:@"chufangjilu" title:@"处方记录" mineBtnType:WPMineBtnTypesSixth];
    [self addSubview:firstBtn];
    [self addSubview:secondBtn];
    [self addSubview:thirdBtn];
    [self addSubview:fourthBtn];
    [self addSubview:fifthBtn];
    [self addSubview:sixthBtn];
    
    [firstBtn addTarget:self action:@selector(mineBtnTypeDidClick:) forControlEvents:UIControlEventTouchDown];
    [secondBtn addTarget:self action:@selector(mineBtnTypeDidClick:) forControlEvents:UIControlEventTouchDown];
    [thirdBtn addTarget:self action:@selector(mineBtnTypeDidClick:) forControlEvents:UIControlEventTouchDown];
    [fourthBtn addTarget:self action:@selector(mineBtnTypeDidClick:) forControlEvents:UIControlEventTouchDown];
    [fifthBtn addTarget:self action:@selector(mineBtnTypeDidClick:) forControlEvents:UIControlEventTouchDown];
    [sixthBtn addTarget:self action:@selector(mineBtnTypeDidClick:) forControlEvents:UIControlEventTouchDown];
    
     UIView *firstLine = [self lineView];
     UIView *secondLine = [self lineView];
     UIView *thirdLine = [self lineView];
     UIView *fourthLine = [self lineView];
     UIView *fifthLine = [self lineView];
    
    
    [firstBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(76.5*SCALE);
        make.width.mas_equalTo(SCREEN_WIDTH/3);
        make.top.left.equalTo(self);
    }];
    
    [secondBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(firstBtn);
        make.width.mas_equalTo(firstBtn);
        make.left.equalTo(firstBtn.mas_right);
    }];
    
    [thirdBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(secondBtn);
         make.width.mas_equalTo(firstBtn);
        make.left.equalTo(secondBtn.mas_right);
    }];
    
    [fourthBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.equalTo(firstBtn);
        make.top.equalTo(firstBtn.mas_bottom);
    }];
    
    [fifthBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.equalTo(secondBtn);
        make.top.equalTo(secondBtn.mas_bottom);
    }];
    
    [sixthBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.equalTo(thirdBtn);
        make.top.equalTo(thirdBtn.mas_bottom);
    }];
    
    [firstLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.left.right.top.equalTo(self);
    }];
    
    [secondLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.bottom.left.right.equalTo(self);
    }];
    
    [thirdLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.left.equalTo(self).offset(15);
        make.right.equalTo(self).offset(-15);
        make.top.equalTo(firstBtn.mas_bottom);
    }];
    
    [fourthLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(0.5);
        make.top.bottom.equalTo(self);
        make.left.equalTo(firstBtn.mas_right);
    }];
    
    [fifthLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(0.5);
        make.top.bottom.equalTo(self);
        make.left.equalTo(secondBtn.mas_right);
    }];

}

-(void)mineBtnTypeDidClick:(WPMineButton *)btn
{
    if ([self.delegate respondsToSelector:@selector(WPMineSecondViewDelegate:mineClickType:)]) {
        [self.delegate WPMineSecondViewDelegate:self mineClickType:btn.btnType];
    }
}


-(UIView *)lineView
{
    UIView *lineView = [UIView new];
    lineView.backgroundColor = RGB_SAME(220);
    [self addSubview:lineView];
    return lineView;
}

@end









